Fix #12910 FP containerOutOfBounds with overloaded template function#7453
Fix #12910 FP containerOutOfBounds with overloaded template function#7453chrchr-github merged 3 commits intocppcheck-opensource:mainfrom
Conversation
| if (matches.size() == 1) | ||
| if (matches.size() == 1 && std::none_of(functionList.begin(), functionList.end(), [tok](const Function& f) { | ||
| const auto nTok = tok->str().size(); | ||
| return startsWith(f.name(), tok->str()) && f.name().size() > nTok + 2 && f.name()[nTok + 1] == '<'; |
There was a problem hiding this comment.
| return startsWith(f.name(), tok->str()) && f.name().size() > nTok + 2 && f.name()[nTok + 1] == '<'; | |
| return startsWith(f.name(), tok->str() + "<") && f.name().size() > nTok + 2; |
I still feel it's hacky but this seems better.
There was a problem hiding this comment.
The function name seems to be func < arg > instead of func<arg> for some reason.
There was a problem hiding this comment.
yeah there is (sometimes?) space before the "<" . we did not used to have it. maybe the extra spaces are removed in the future again who knows.
There was a problem hiding this comment.
If you have examples for either case I will see if I can bisect this.
There was a problem hiding this comment.
If you have examples for either case I will see if I can bisect this.
The spaces appear in the output of --debug -v (e.g. name:), but I don't know what the significance is.
There was a problem hiding this comment.
template <class T> void fun()
{
}
int main()
{
fun<int>();
}1.77
1:
|
4:
5: int main ( )
6: {
7: fun<int> ( ) ;
8: } void fun<int> ( )
2: {
3: }
[...]
Scope: 000001F7E6853E30 Function
className: fun<int>
[...]
##AST
( 'signed int'
`-main
( 'void'
`-fun<int>
( 'void'
`-fun<int>
1.78
1:
|
4:
5: int main ( )
6: {
7: fun < int > ( ) ;
8: } void fun < int > ( )
2: {
3: }
[...]
Scope: 000001CBB41650D0 Function
className: fun < int >
[...]
##AST
( 'signed int'
`-main
( 'void'
`-fun < int >
( 'void'
`-fun < int >
1.82
1:
|
4:
5: int main ( )
6: {
7: fun<int> ( ) ;
8: } void fun<int> ( )
2: {
3: }
[...]
Scope: 000001E34CC268D0 Function
className: fun < int >
[...]
##AST
( 'signed int'
`-main
( 'void'
`-fun < int >
( 'void'
`-fun < int >
There was a problem hiding this comment.
Something in here we need to file a ticket about?
There was a problem hiding this comment.
The inconsistent use of spaces in template names, perhaps.
There was a problem hiding this comment.
I agree.. it feels like there could be cases that does not work as wanted. |
danmar
left a comment
There was a problem hiding this comment.
well I can accept this. If the space is removed in the future we'll have to change this.
Feels hacky though.